package com.ruoyi.web.controller.wfshou;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.wfshou.domain.UserProj;
import com.ruoyi.wfshou.service.IUserProjService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 人员管理Controller
 * 
 * @author zongying
 * @date 2023-06-19
 */
@RestController
@RequestMapping("/wfshou/projHR")
public class UserProjController extends BaseController
{
    @Autowired
    private IUserProjService userProjService;

    /**
     * 查询人员管理列表
     */
    @PreAuthorize("@ss.hasPermi('wfshou:projHR:list')")
    @GetMapping("/list")
    public TableDataInfo list(UserProj userProj)
    {
        System.out.println("调用查找方法0");
        startPage();
        List<UserProj> list = userProjService.selectUserProjList(userProj);
        return getDataTable(list);
    }

    @GetMapping("/listByProj")
    public TableDataInfo listByProj(UserProj userProj)
    {
        List<UserProj> list = userProjService.selectUserProjList(userProj);
        return getDataTable(list);
    }
    /**
     * 导出人员管理列表
     */
    @PreAuthorize("@ss.hasPermi('wfshou:projHR:export')")
    @Log(title = "人员管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, UserProj userProj)
    {
        List<UserProj> list = userProjService.selectUserProjList(userProj);
        ExcelUtil<UserProj> util = new ExcelUtil<UserProj>(UserProj.class);
        util.exportExcel(response, list, "人员管理数据");
    }

    /**
     * 获取人员管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('wfshou:projHR:query')")
    @GetMapping(value = "/{userId}")
    public AjaxResult getInfo(@PathVariable("userId") Long userId)
    {
        return success(userProjService.selectUserProjByUserId(userId));
    }

    /**
     * 新增人员管理
     */
    @PreAuthorize("@ss.hasPermi('wfshou:projHR:add')")
    @Log(title = "人员管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody UserProj userProj)
    {
        return toAjax(userProjService.insertUserProj(userProj));
    }

    /**
     * 修改人员管理
     */
    @PreAuthorize("@ss.hasPermi('wfshou:projHR:edit')")
    @Log(title = "人员管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody UserProj userProj)
    {
        return toAjax(userProjService.updateUserProj(userProj));
    }

    /**
     * 删除人员管理
     */
    @PreAuthorize("@ss.hasPermi('wfshou:projHR:remove')")
    @Log(title = "人员管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{userIds}")
    public AjaxResult remove(@PathVariable Long[] userIds)
    {
        return toAjax(userProjService.deleteUserProjByUserIds(userIds));
    }

}
